﻿using BigEgg.Framework.Foundation;
using BigEgg.Framework.UnitTesting;
using FMStudio.Domain.Properties;
using FMStudio.Domain.SQLite;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Globalization;

namespace FMStudio.Domain.SQLite.Test
{
    [TestClass]
    public class UseTypeTest
    {
        [TestMethod]
        public void GeneralUseTypeTest()
        {
            UseType useType = new UseType();

            Assert.IsNotNull(useType.ID);
            Assert.AreEqual("", useType.Name);

            useType.Name = "Food";

            Assert.AreEqual("", useType.Validate());
        }

        [TestMethod]
        public void UseTypeNameValidationTest()
        {
            UseType useType = new UseType();

            Assert.AreEqual(string.Empty, useType.Name);
            Assert.AreEqual(Resources.UseTypeNameMandatory, useType.Validate("Name"));

            useType.Name = TestHelper.CreateString('A', 99);
            Assert.AreEqual("", useType.Validate("Name"));
            useType.Name = TestHelper.CreateString('A', 100);
            Assert.AreEqual("", useType.Validate("Name"));
            useType.Name = TestHelper.CreateString('A', 101);
            Assert.AreEqual(
                string.Format(CultureInfo.CurrentCulture, Resources.UseTypeNameMaxLength, "Name", 100)
                , useType.Validate("Name"));
        }
    }
}
